package action;

import service.UserManager;

import com.opensymphony.xwork2.Action;

public class validateNameAction implements Action {
	private String user;
	private String tip;
	private UserManager mgr;

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getTip() {
		return tip;
	}

	public void setTip(String tip) {
		this.tip = tip;
	}

	public void setMgr(UserManager mgr) {
		this.mgr = mgr;
	}

	public String execute() {
		// TODO Auto-generated method stub
		try{
			if(mgr.validateName(user) && user != null && user.length()!=0){
				setTip("hello! " + user + " this name is available!");
			}else{
				setTip("this " + user + " has already existed!");
			}
		}catch(Exception e){
			setTip("");
		}
		return SUCCESS;
	}

}
